#include "cIdManager.h"

cIdManager::cIdManager(void)
{
}

cIdManager::~cIdManager(void)
{
	Free();
}

//BOOL cIdManager::Init()
//{
//	return TRUE;
//}

BOOL cIdManager::Free()
{
	this->m_MyWindowMap.clear();
	//this->m_MySuperActionFlag.clear();
	//this->m_MyActionFlag.clear();

	return TRUE;
}

void cIdManager::TellIDType(IDTYPE idtype)
{
	switch(idtype)
	{
	case FRAME_MYWINDOW:
		cout<<"FRAME_IDTYPE is "<<idtype<<", type is FRAME_MYWINDOW";
		break;
	//case SUPER_ACTION_FLAG:
	//	cout<<"SUPER_ACTION_FLAG is "<<idtype<<", type is SUPER_ACTION_FLAG";
	//	break;
	//case ACTION_FLAG:
	//	cout<<

	default:
		cout<<"cIdManager::TellIDType(IDTYPE idtype)~Exception"<<endl;
		break;
	}
	return;
}

BOOL cIdManager::IsIDRegisted(std::string id, IDTYPE idtype)
{
	switch(idtype)
	{
	case FRAME_MYWINDOW:

		if( this->m_MyWindowMap.count(id) >0 ) 
		{
			if (this->m_MyWindowMap[id] == true)
			{
				return TRUE;
			}
			return FALSE;
		}
		else
		{
			return FALSE;
		}
		break;

	//case SUPER_ACTION_FLAG:

	//	return FALSE;
	//	break;

	//case ACTION_FLAG:
	//	
	//	return FALSE;
	//	break;

	default:
		cout<<"cIdManager::IsIDRegisted(std::string id, IDTYPE idtype)~Exception"<<endl;
		return ID_TYPE_NOT_FOUND;
		break;
	}
	return TRUE;

}

BOOL cIdManager::ManualRegisterID(string id, IDTYPE idtype)
{
	if(IsIDRegisted(id,idtype) == TRUE)
	{
		cout<<"Error: in ManualRegisterID, id='"<<id<<"'"<<endl;
		return FALSE;
	}
	
	switch(idtype)
	{
	default:
		cout<<"cIdManager::ManualRegisterID(string id, IDTYPE idtype)~Exception"<<endl;
		return FALSE;
		break;

	case FRAME_MYWINDOW:
		this->m_MyWindowMap[id] = true;
		break;

	//case SUPER_ACTION_FLAG:
	//	this->m_MySuperActionFlag.push_back(id);
	//	break;
	//
	//case ACTION_FLAG:
	//	this->m_MyActionFlag.push_back(id);
	//	break;

	}

	return TRUE;
}

BOOL cIdManager::UnregisterID(string id,IDTYPE idtype)
{
	//vector<string>::iterator actionA = this->m_MySuperActionFlag.begin();
	//vector<string>::iterator actionB = this->m_MyActionFlag.begin();


	switch(idtype)
	{

	default:
		cout<<"cIdManager::UnregisterID(string id,IDTYPE idtype)~Exception"<<endl;
		return FALSE;

		break;

	case FRAME_MYWINDOW:

		if (this->m_MyWindowMap.count(id) >0 )
		{
			this->m_MyWindowMap[id] = false;
		}

		break;

	//case SUPER_ACTION_FLAG:

	//	while( (actionA!=m_MySuperActionFlag.end()) && (!m_MySuperActionFlag.empty()) )
	//	{
	//		if(!(*actionA).compare(id))
	//		{
	//			actionA = this->m_MySuperActionFlag.erase(actionA);
	//			return TRUE;
	//		}
	//		actionA++;
	//	}
	//	return ID_NOT_FOUND;

	//	break;

	//case ACTION_FLAG:

	//	while( (actionB!=m_MyActionFlag.end()) && (!m_MyActionFlag.empty()) )
	//	{
	//		if(!(*actionB).compare(id))
	//		{
	//			actionB = this->m_MyActionFlag.erase(actionB);
	//			return TRUE;
	//		}
	//		actionB++;
	//	}
	//	return ID_NOT_FOUND;

	//	break;

	}

	return TRUE;
}
//
//vector<string>* cIdManager::GetSuperActionFlagPtr()
//{
//	return &m_MySuperActionFlag;
//}
//
//vector<string>* cIdManager::GetActionFlagPtr()
//{
//	return &m_MyActionFlag;
//}